package schoolword;
class A{
    int i,j;
    void showij() {
        System.out.println("i and j:" + i + " " + j);
    }
}
class B extends A{     //B类继承A类
    int k;
    int i,j;
    void showk() {
        System.out.println("k:" + k);
    }
    void sum() {
        System.out.println("i + j + k:" + (i + j + k));
    }

    @Override
    void showij() {
        System.out.println("覆盖了父类的成员方法");
    }
}
public class M1 {
    public static void main(String[] args) {
        A father = new A();
        B son = new B();   //使用B类创建对象son
        father.i = 10;
        father.j = 20;
        father.showij();
        son.i = 7;
        son.j = 8;
        son.k = 9;
        son.showij();
        son.showk();
        son.sum();   //调用对象son中的方法sum（）来求和
    }
}
